﻿
@{
    ViewBag.Title = "添加商品服务";
}
@section CSS{
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            @ViewBag.text
            <small>商品服务</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">系统管理</a></li>
            <li><a href="/SystemSetting/Service">商品服务列表</a></li>
            <li class="active">@ViewBag.text 商品服务</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <div class="ibox float-e-margins">

                            <div class="ibox float-e-margins">
                                <div class="ibox-content">
                                    <form class="form-horizontal" id="from-add" novalidate="novalidate" method="post" action="/SystemSetting/AddorEditService">
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">服务名称 <span style="color:red;">*</span>：</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="title" id="title" value="" class="form-control" placeholder="服务标题" required="" aria-required="true" />
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">排序：</label>
                                            <div class="col-sm-9">
                                                <input type="text" name="sort" id="sort" value="99" class="form-control" placeholder="排序" />
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">服务内容：</label>
                                            <div class="col-sm-9">
                                                <textarea name="content" id="content" maxlength="1000" class="form-control" placeholder="请输入服务内容" rows="4"></textarea>
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-3 control-label">备注：</label>
                                            <div class="col-sm-9">
                                                <textarea name="remark" id="remark" maxlength="500" class="form-control" placeholder="请输入服务内容" rows="3"></textarea>
                                                <span class="help-block m-b-none"></span>
                                            </div>
                                        </div>

                                        <input type="hidden" id="id" value="0" name="id">

                                        <div class="form-group">
                                            <div class="col-sm-4 col-sm-offset-3">
                                                <button class="btn btn-primary" type="submit">保存信息</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

</div>

@section JS{
    <script src="~/Content/js/jquery.form.js"></script>
    <script src="~/Content/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/Content/plugins/validate/messages_zh.min.js"></script>

    <script type="text/javascript">
        var _id = "@ViewBag.id";
        $(function () {
            if (_id != undefined && _id!="0")
            {getinfo(_id);}
        });


        function getinfo(_id) {
            ajax("/SystemSetting/ServiceInfo/" + _id, {}, function (data) {
                if (data!= null) {
                    $("#id").val(data.id);
                    $("#title").val(data.title);
                    $("#content").text(data.content);
                    $("#remark").text(data.remark);
                    $("#sort").val(data.sort);
                    
                    //服务名称唯一，禁止修改
                    //$("#title").attr("readonly", "readonly");
                }
                else {
                    layer.alert('信息获取失败，请重试！', { icon: 5 });
                }
            }, true, "", "get");
        }

        $("#from-add").validate({
            ajaxPost: true,
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    success: function (result) {
                        if (result.status == "y") {
                            layer.msg("操作成功", { icon: 6, time: 1200 }, function () {
                                window.location.href = "/SystemSetting/Service";
                            });
                        }
                        else {
                            layer.msg(result.info, { icon: 5, time: 2000 });
                        }
                    }
                });
            }
        });
    </script>
}

